package com.vecspace.dayu.code.dao;

import org.springframework.stereotype.Repository;

import com.vecspace.database.dao.BaseDao;
import com.vecspace.dayu.code.pojo.UserProperty;

/** DAYU-用户配置信息,操作数据库的dao类
 * @author: wanghua
 * @reviewer:
 */
@Repository("dayu_userPropertyDao")
public class UserPropertyDao extends BaseDao {
	/** 根据ID查询 DAYU-用户配置信息
	 * @param id   主键值
	 * @return UserProperty
	 * @throws Exception
	 * @author wanghua
	 */
	public UserProperty getUserProperty(Long id) throws Exception {
		UserProperty userProperty = null;
		if (id != null && id != 0) {

			userProperty = this.queryObject(UserProperty.class, id);
			this.evict(userProperty);
		}
		return userProperty;
	}
	
	public UserProperty getUserProperty(String loginId, String propName) throws Exception {
		UserProperty userProperty = this.queryObject("from UserProperty where loginId=?0 and propName=?1", new Object[] {loginId, propName});		
		return userProperty;
	}

	/** 插入或修改 DAYU-用户配置信息 
	 * @param item	要保存的对象
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void saveUserProperty(UserProperty item) throws Exception {
		this.saveOrUpdateObject(item);
		this.evict(item);
	}

	/** 根据ID删除 DAYU-用户配置信息 
	 * @param id	主键值
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void deleteUserProperty(Long id) throws Exception {
		if (id != null && id != 0) {
			this.deleteObject(UserProperty.class, id);
		}
	}
}
